<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
    <%--常量--%>
    <%@ include file="/common/constHead.jsp"%>
    <%--jQuery--%>
    <%@ include file="/common/jqueryHead.jsp"%>
    <%--jo--%>
    <%@ include file="/common/joHead.jsp"%>
    <%--bootstrap和字体--%>
    <%@ include file="/common/bootstrapHead.jsp"%>
    <%--layer--%>
    <%@ include file="/common/layerHead.jsp"%>
    <%--公共--%>
    <%@ include file="/common/commonHead.jsp"%>
    <%--日期选择--%>
    <%@ include file="/common/dateHead.jsp"%>
    <title>保护地空间位置坐标信息表单</title>
    <script type="text/javascript">
        $(function(){
            var jParams = {
                "PKName" : "id",//主键属性名
                "saveAfter" : "toEdit",
                "addUrl" : "travel/natureReserveSpatialinfo/insert.action",//新增
                "deleteUrl" : "travel/natureReserveSpatialinfo/delete.action",//删除
                "updateUrl" : "travel/natureReserveSpatialinfo/update.action",//修改
                "formDataUrl" : "travel/natureReserveSpatialinfo/get.action"	//查询
            };
            joForm.initFormPage(jParams);//初始化
        });
        //初始化表单值前处理
        joForm.initFormValueBefore = function(oJson){
        };
        //获取保护地空间位置信息数据回显到表单
        function getSpatialLocationData() {
            //清空table
            top.positionTable.html("");
            var reserveId = top.reserveId;
            jo.postAjax("travel/natureReserveSpatialinfo/getListByReserveId.action",{"reserveId":reserveId},function (json) {
                if(json && json.code == 0){//后台执行成功

                    if(json.data && json.data.length > 0){//查询出有保护地对应功能区的空间位置信息数据
                        var data = json.data;
                        console.info(data);
                        for(var i = 0; i < data.length; i++){
                            var funType = data[i].type;
                            var position = data[i].position;
                            //拼接要回显的功能分区位置坐标信息
                            var _html = '<tr>' +
                                '<td width="15%" class="active" align="" style="display: none;">'+id+'</td>'+
                                '<td width="15%" class="active" align="">'+funType+'</td>' +
                                '<td class="tnt" colspan="3"><input type="text"' +
                                'name="" id="funCoordinate" class="form-control input-sm"' +
                                'placeholder="暂无该分区,请填充数据" value="'+position+'" /></td>' +
                                '</tr>';
                            top.positionTable.append(_html);
                        }
                    }
                }
            });
        }
        //新增成功的回调
        joForm.saveSuccessAfter = function(result){
            //关闭自己
            jo.closeSelf();
            getSpatialLocationData();
        }
    </script>
</head>
<body>
<div class="container-fluid">
    <div class="row">
        <div class="col-xs-12">
            <!--按钮栏-->
            <div class="form-group button-bar">
                <button type="button" isShow="joForm.isAdd" class="btn btn-sm btn-outline btn-default" onclick="joForm.save()">
                    <i class="fa fa-plus-circle" aria-hidden="true"></i>&nbsp;新增
                </button>
                <button type="button" isShow="!joForm.isAdd" class="btn btn-sm btn-outline btn-default" onclick="joForm.update()">
                    <i class="fa fa-pencil-square" aria-hidden="true"></i>&nbsp;修改
                </button>
                <button type="button" isShow="!joForm.isAdd" class="btn btn-sm btn-outline btn-default" onclick="joForm.del()">
                    <i class="fa fa-trash" aria-hidden="true"></i>&nbsp;删除
                </button>
            </div>
            <!--按钮栏-->
        </div>
    </div>
    <div class="row">
        <div class="col-xs-12">
            <form id="pageForm" name="pageForm" action="" method="post">
                <input type="text"   name="reserveid" class="form-control input-sm " style="display: none;" value="" id="reserveid"/>
                <input type="text"   name="id" class="form-control input-sm " style="display: none;" value="" />
                <table class="table table-bordered  table-condensed dataTables-example dataTable no-footer">
                    <%--<tr>
                        <td width="15%" class="active " align="">主键id</td>
                        <td class="tnt">
                            <input type="text"   name="id" class="form-control input-sm readonly-edit"  />
                        </td>
                        <td width="15%" class="active " align="">保护地id</td>
                        <td class="tnt">
                            <input type="text"   name="reserveid" class="form-control input-sm "  />
                        </td>
                    </tr>--%>
                    <tr>
                        <td width="15%" class="active must" align="">功能分区</td>
                        <td class="tnt">
                            <select class="form-control input-sm " ErrEmpty name="type">
                                <option value="保护区地理坐标">保护区地理坐标</option>
                                <option value="实验区地理坐标">实验区地理坐标</option>
                                <option value="缓冲区地理坐标">缓冲区地理坐标</option>
                                <option value="核心区地理坐标">核心区地理坐标</option>
                            </select>
                        </td>
                        <td width="15%" class="active" align="">精度</td>
                        <td class="tnt">
                            <input type="text"   name="precision" class="form-control input-sm "/>
                        </td>
                    </tr>
                        <tr>
                            <td width="15%" class="active must" align="">位置坐标</td>
                            <td class="tnt" colspan="3">
                                <input type="text"   name="position" class="form-control input-sm " ErrEmpty />
                            </td>
                        </tr>
                </table>
            </form>
        </div>
    </div>
</div>
<script>
    var spatialId = top.spatialId;
    $("#reserveid").val(spatialId);
</script>
<script src="<%=URL_STATIC%>static/plugin/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<script type="text/javascript">
    jo.formatUI();//格式化jo组件
</script>
</body>
</html>
